package cn.semcorp.zhuhaizj.quartzConfig;

import cn.semcorp.zhuhaizj.quartzJob.TobeRedisJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzRedisConfiguration {

    @Bean
    public JobDetail showRedisJob(){
        return JobBuilder.newJob(TobeRedisJob.class)
                .withIdentity("tobeRedisJob")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger showRedisTrigger(){
        CronScheduleBuilder cron =
            CronScheduleBuilder.cronSchedule("0 0 */2 * * ? *");
//                    CronScheduleBuilder.cronSchedule("0/20 * * * * ? *");

        return TriggerBuilder.newTrigger()
                .withSchedule(cron)
                .withIdentity("showRedisTrigger")
                .forJob(showRedisJob())
                .build();
    }
}
